function* flat (arr) {
  for (let item of arr) {
    if (Array.isArray(item)) yield * flat(item)
    else yield item
  }
}

function flattenDeep (arr) {
  let result = []
  for (let val of flat(arr)) {
    result.push(val)
  }
  return result
}
export default flattenDeep
